<?php

class Core_Backend_Component_Promotion_View_Position_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('promotion/position/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.apply'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'apply')."')");
        $group->addButton($this->__('share.button.save'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'save')."')");
        parent::buildToolBar($toolbar);
    }

    public function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('position_form')
                ->addHiddenField('id', 'position[id]');
        $form->addTextboxField($this->__('share.label.code'), 'code', 'position[code]', TRUE)
                ->addRequiredRule()
                ->addCharacterRule();
        $form->addTextboxField($this->__('share.label.name'), 'name', 'position[name]', TRUE)
                ->addRequiredRule();
        $form->addTextBoxField($this->__('promotion.label.width'),'width','position[width]')->getField();
        $form->addTextBoxField($this->__('promotion.label.height'),'height','position[height]')->getField();
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}

